package com.xzy.Config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;

@Configuration
@EnableSwagger2//开启swagger2
public class SwaggerConfig {

    @Bean
    public Docket docket(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .groupName("顺丰炎师傅")
                .enable(true)
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.xzy.Controller"))
                .build()//工厂模式
                ;
    }

    private ApiInfo apiInfo(){
        Contact contact =
                new Contact("顺丰炎师傅著","https://www.bilibili.com/","2339806461@qq.com");
        return new ApiInfo(
                "顺丰炎师傅-swagger api文档日记",
                "顺丰炎师傅",
                "1.0",
                "https://www.bilibili.com/",
                contact,
                "Apache 2.0",
                "http://www.apache.org/licenses/LICENSE-2.0",
                new ArrayList()
        );
    }
};

